package cn.ubeta.b2c.utils;

import android.app.Activity;
import android.view.View.OnClickListener;

import cn.ubeta.b2c.R;
import cn.ubeta.b2c.widget.TitleBar;

/**
 * Created by liudengyong on 16/8/29.
 */

public class TitleBarHelper {

    /**
     * 设置标题
     */
    public static void setTitle(Activity activity, String title) {
        ((TitleBar) activity.findViewById(R.id.title_bar)).setTitle(title);
    }

    /**
     * 设置返回键
     */
    public static void setBack(Activity activity) {
        ((TitleBar) activity.findViewById(R.id.title_bar)).setLeftClickListener(v -> activity.finish());
    }

    /**
     * 设置右侧按钮动作
     * @param activity
     * @param name
     * @param listener
     */
    public static void setRightAction(Activity activity, String name, OnClickListener listener) {
        ((TitleBar) activity.findViewById(R.id.title_bar)).setAction(name, listener);
    }
}
